package cn.wokoba.dao.mapper;

import cn.wokoba.dao.pojo.RaffleActivityStage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RaffleActivityStageMapper extends BaseMapper<RaffleActivityStage> {


    @Select("select state from raffle_activity_stage where activity_id= #{activityId}")
    String queryCurrActivityState(Long activityId);

    @Select("select activity_id from raffle_activity_stage where source= #{source} and channel =#{channel} ")
    Long queryStageActiveBySC(RaffleActivityStage raffleActivityStage);

    @Select("select id, channel, source, activity_id, state from raffle_activity_stage where state='pass' or state = 'open'")
    List<RaffleActivityStage> queryStageActivityList();

    @Update("update raffle_activity_stage set state= #{endState} where activity_id= #{activityId} and state = #{currState}")
    void alterActivityStage(Long activityId, String currState, String endState);

}